package com.studies.pc.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.studies.common.R.R;
import com.studies.pc.pojo.Activity;
import com.studies.pc.pojo.BaseInfo;
import com.studies.pc.pojo.BaseInfoWithBlobs;
import com.studies.pc.pojo.EvaluateInfo;
import com.studies.pc.service.BaseInfoService;
import com.studies.pc.query.BaseInfoQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 基地 前端控制器
 * </p>
 *
 * @author 研学活动后台
 * @since 2019-12-24
 */
@Api(tags="基地模块")
@CrossOrigin //跨域
@RestController
@RequestMapping("/pc/base-info")
public class BaseInfoController {
    @Autowired
    private BaseInfoService baseInfo;
    @ApiOperation(value = "分页基地列表")
    @PostMapping(value = "qryBaseInfoPage{nowPage}/{pageSize}")
    public R selectPage(@ApiParam(name = "nowPage", value = "当前页码", required = true)
                        @PathVariable Long nowPage,

                        @ApiParam(name = "pageSize", value = "每页记录数", required = true)
                        @PathVariable Long pageSize,
                        @ApiParam(name = "baseInfoQuery", value = "条件", required = false)
                                BaseInfoQuery baseInfoQuery){

        Page<BaseInfo> pageParam = new Page<BaseInfo>(nowPage, pageSize);

        Map<String, Object> map = baseInfo.qryBaseInfoPage(pageParam,baseInfoQuery);

        return  R.ok().data(map);
    }

    @ApiOperation(value = "基地详情")
    @PostMapping(value = "qryBaseInfoWithBlobs/{id}")
    public R selectifo(@ApiParam(name = "id", value = "基地id", required = true)
                           @PathVariable Integer id){
        BaseInfoWithBlobs baseInfoWithBlobs = baseInfo.qryBaseInfoWithBlobs(id);
        return  R.ok().data("itms",baseInfoWithBlobs);
    }

    @ApiOperation(value = "基地评分")
    @PostMapping(value = "qryBaseEvaluateInfo/{id}")
    public R qryBaseEvaluateInfo(@ApiParam(name = "id", value = "基地id", required = true)
                       @PathVariable Integer id){
        EvaluateInfo evaluateInfo = baseInfo.qryBaseEvaluateInfo(id);
        return  R.ok().data("itms",evaluateInfo);
    }
    @ApiOperation(value = "基地评分分页")
    @PostMapping(value = "qryBaseEvaluatePage/{id}")
    public R qryUndertakeOrgEvaluateInfo(@ApiParam(name = "id", value = "基地id", required = true)
                                         @PathVariable Integer id,
                                         @ApiParam(name = "nowPage", value = "当前页码", required = true)
                                         @PathVariable Long nowPage,
                                         @ApiParam(name = "pageSize", value = "每页记录数", required = true)
                                             @PathVariable Long pageSize){
        Page<EvaluateInfo> pageParam = new Page<EvaluateInfo>(nowPage, pageSize);
        Map<String, Object> map = baseInfo.qryBaseEvaluatePage(pageParam,id);
        return  R.ok().data(map);
    }
}

